-- the_departed
-- created by zhuangsl
-- 击杀特定敌人获得属性提升BUFF

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 击杀触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_USER then
            return;
        end

        local target = arg;
        if target.type ~= OBJECT_TYPE_MONSTER then
            return;
        end

        local baseClassId = target:query("base_class_id");
        if baseClassId ~= tonumber(prop[2]) then
            return;
        end

        -- 取当前已累加的属性
        local condition = CombatStatusM.queryCondition(who, "the_departed") or {};
        local value = condition["value"] or 0;

        -- 新的属性
        value = value + prop[3];

        local newCondition = {
            ["value"] = value,
            ["end_round"] = -1,
        }

        -- 更新状态
        CombatStatusM.applyStatus(who, "the_departed", newCondition);
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local base_class_id = tonumber(prop[2]);
        desc = string.gsub(desc, "{0}", MonsterM.query(base_class_id, "name"));

        local v = prop[3];
        desc = string.gsub(desc, "{1}", v);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};
